package command;

import object.Blob;
import object.Stage;
import object.Tree;

import java.io.File;

public class AddCommand {
    File file;

    public AddCommand(String path){

        file = new File(path);
    }

    public void excute() throws Exception{
        Stage stage = Stage.deserialize();

        if( file.isFile()) {
            Blob blob = new Blob(file);
            stage.updateStage(blob);
        }
        else {
            Tree tree = new Tree(file);
            stage.updateStage(tree);
        }
        stage.writeObject();
    }
}
